////////////////////////////////////////////////
// -- DepthHUD Lite                           //
// by Hurricaaane (Ha3)                       //
//                                            //
// http://www.youtube.com/user/Hurricaaane    //
//--------------------------------------------//
// Shared Autorun                             //
////////////////////////////////////////////////

if DHLITE_DEBUG == nil then
	DHLITE_DEBUG = false
end

-- Developer notes :
--   "--" comments should be used for regular comments.
--   "//" comments should be used for debugging / technical / header comments.

//DHLITE_DEBUG = true

DHLITE_FORCE_VERSION = false
DHLITE_FORCE_USE_CLOUD = true

DHLITE_NAME = "DepthHUD Lite"
DHLITE_EXTENDDIR  = "dhlite_extend/"

if (CLIENT) then
	if (dhlite and dhlite.Unmount) then dhlite.Unmount() end
	
	include("cl_dhlite_cloudloader.lua")
	include("cl_dhlite_version.lua")
	
	if not DHLITE_FORCE_VERSION then
		local function DHLITE_CheckResponse()
			if not dhlite_internal.HasReceivedResponse() then
				print(" > " .. DHLITE_NAME .. " did not get a response from Cloud Version query. Now loading Locale.")
				dhlite_cloud.LoadLocale()
				
			end
			
		end
		
		local function DHLITE_CallbackResponse()
			local MY_VERSION, ONLINE_VERSION, DOWNLOAD_LINK = dhlite_internal.GetVersionData()
			if MY_VERSION < ONLINE_VERSION then
				print(" > " .. DHLITE_NAME .. " found an updated version from the Cloud (Locale is ".. MY_VERSION .. ", Online is " .. ONLINE_VERSION .. "). Now querying Cloud.")
				dhlite_cloud.Ask()
			
			else
				print(" > " .. DHLITE_NAME .. " Locale seems as up to date as the Cloud. Loading Locale.")
				dhlite_cloud.LoadLocale()
				
			end
			
		end
		
		print(" > " .. DHLITE_NAME .. " is in normal mode. Now querying Version.")
		dhlite_internal.QueryVersion( DHLITE_CallbackResponse )
		timer.Simple( 10, DHLITE_CheckResponse )
	
	elseif DHLITE_FORCE_USE_CLOUD then
		print(" > " .. DHLITE_NAME .. " is in Cloud force mode. Now querying Cloud.")
		dhlite_cloud.Ask()
		
	else
		print(" > " .. DHLITE_NAME .. " is in Locale force mode. Now loading Locale.")
		dhlite_cloud.LoadLocale()
		
	end
	
end
